/*
 * @Description:
 * @Author: your name
 * @version:
 * @Date: 2024-06-24 09:20:01
 * @LastEditors: your name
 * @LastEditTime: 2024-06-25 10:18:14
 */
import api from "./request"

// 楼栋相关API
export const getBuildings = () => api.get(`/building/getBuildings`)
export const addBuilding = (params) => api.post(`/building/addBuilding`, params)
export const updateBuilding = (id, params) =>
  api.put(`/building/updateBuilding/${id}`, params)
export const deleteBuilding = (id) =>
  api.delete(`/building/deleteBuilding/${id}`)

// 单元相关API
export const getUnitsByBuilding = (buildId) =>
  api.get(`/unit/getUnitsByBuilding/${buildId}`)
export const addUnit = (params) => api.post(`/unit/addUnit`, params)
export const updateUnit = (id, params) =>
  api.put(`/unit/updateUnit/${id}`, params)
export const deleteUnit = (id) => api.delete(`/unit/deleteUnit/${id}`)

// 住户相关API
export const getHouseholdsByUnit = (unitId) =>
  api.get(`/household/getHouseholdsByUnit/${unitId}`)
export const getHousehold = (id) => api.get(`/household/getHousehold/${id}`)
export const addHousehold = (params) =>
  api.post(`/household/addHousehold`, params)
export const updateHousehold = (id, params) =>
  api.put(`/household/updateHousehold/${id}`, params)
export const deleteHousehold = (id) =>
  api.delete(`/household/deleteHousehold/${id}`)

// 费用相关API
export const getHouseholdFees = (params) =>
  api.get(`/household/getHouseholdsByBuilding/${params.building_id}`, {
    params,
  })
export const updateHouseholdFee = (id, data) =>
  api.put(`/household/updateHousehold/${id}`, {
    water_fee: data.water_fee,
    electric_fee: data.electric_fee,
    property_fee: data.property_fee,
    is_paid: data.is_paid,
  })
export const payHouseholdFee = (id) =>
  api.put(`/household/updateHousehold/${id}`, { is_paid: true })

// 标记点相关 API
export const getMarkers = () => api.get("/marker/getMarkers")
export const addMarker = (data) => api.post("/marker/addMarker", data)
export const updateMarker = (id, data) =>
  api.put(`/marker/updateMarker/${id}`, data)
export const deleteMarker = (id) => api.delete(`/marker/deleteMarker/${id}`)

// 物业人员相关API
export const getPropertyStaff = () => api.get("/staff/getPropertyStaff")
export const addPropertyStaff = (data) =>
  api.post("/staff/addPropertyStaff", data)
export const updatePropertyStaff = (id, data) =>
  api.put(`/staff/updatePropertyStaff/${id}`, data)
export const deletePropertyStaff = (id) =>
  api.delete(`/staff/deletePropertyStaff/${id}`)

// 外包人员相关API
export const getOutsourceStaff = () => api.get("/staff/getOutsourceStaff")
export const addOutsourceStaff = (data) =>
  api.post("/staff/addOutsourceStaff", data)
export const updateOutsourceStaff = (id, data) =>
  api.put(`/staff/updateOutsourceStaff/${id}`, data)
export const deleteOutsourceStaff = (id) =>
  api.delete(`/staff/deleteOutsourceStaff/${id}`)
